#include<iostream>
using namespace std;
#include<vector>


int arrx[4] = { 1,-1,0,0 };
int arry[4] = { 0,0,-1,1 };

int getNumber(vector<vector<int>>& grid,int x,int y,int& number)
{
	int length1 = grid.size();
	int length2 = grid[0].size();

	if (grid[x][y] == 1)
	{
		grid[x][y] = 0;
		number++;
		for (int i = 0; i < 4; i++)
		{
			int x1 = x + arrx[i];
			int y1 = y + arry[i];
			if (x1 >= 0 && x1 < length1)
			{
				if (y1 >= 0 && y1 < length2)
				{
					getNumber(grid, x1, y1, number);
				}
			}
		}
	}
	return number;
}


int maxAreaOfIsland(vector<vector<int>>& grid) {
	int length1 = grid.size();
	int length2 = grid[0].size();

	int number = 0;

	for (int i = 0; i < length1; i++)
	{
		for (int j = 0; j < length2; j++)
		{
			int x = 0;
			getNumber(grid, i, j, x);
			if (number < x)
			{
				number = x;
			}
		}
	}
	return number;
}

int main()
{
	return 0;
}